#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/**
 * Definition for singly-linked list.
 */
struct ListNode {
	int val;
	struct ListNode* next;
};
typedef struct ListNode listNode, *listnode;

struct ListNode* reverseBetween(struct ListNode* head, int left, int right);

int main()
{
	return 0;
}

struct ListNode* reverseBetween(struct ListNode* head, int left, int right)
{
	listNode auxHead = { 0, head };
	listnode p1 = &auxHead, p2 = 0, p3 = 0;
	for (int cnt = left - 1; cnt > 0; cnt--)
		p1 = p1->next;
	int cnt = right - left;

	listnode start = p1;
	p1 = p1->next; p2 = p1->next;
	while (cnt > 0) {
		 p3 = p2->next;

		 p2->next = p1;
		 p1 = p2; p2 = p3;
		 cnt--;
	}

	start->next->next = p2;
	start->next = p1;

	return auxHead.next;
}
